//
//  HPSwiperResult.m
//  HPZZTong
//
//  Created by wenjun on 14-5-6.
//  Copyright (c) 2014年 Handpay. All rights reserved.
//

#import "HPSwiperResult.h"

@implementation HPSwiperResult

- (id)initWithCode:(HPSwiperResultCode)code message:(NSString *)message value:(id)value
{
    self = [super init];
    _code = code;
    _value = value;
    _message = message;
    return self;
}

- (BOOL)isSuccess
{
    return _code == HPSwiperResultSuccess;
}

- (BOOL)isCanceld
{
    return _code == HPSwiperResultCancel;
}

- (void)setProperty:(id)obj forKey:(NSString *)key
{
    if (obj != nil)
    {
        if (_properties == nil)
        {
            self.properties = [NSMutableDictionary dictionary];
        }
        [_properties setValue:obj forKey:key];
    }
}

- (id)propertyForKey:(NSString *)key
{
    return [_properties objectForKey:key];
}

+ (HPSwiperResult *)successResult:(id)value
{
    return [[HPSwiperResult alloc] initWithCode:HPSwiperResultSuccess message:nil value:value];
}

+ (HPSwiperResult *)failResultWithCode:(HPSwiperResultCode)failCode
{
    return [[HPSwiperResult alloc] initWithCode:failCode message:nil value:nil];
}

+ (HPSwiperResult *)failResultWithMsg:(NSString *)msg
{
    return [[HPSwiperResult alloc] initWithCode:HPSwiperResultFail message:msg value:nil];
}

@end
